package com.guomai.app.server.db.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guomai.app.server.db.entity.UserEntity;
import com.guomai.app.server.db.mapper.UserMapper;
import org.springframework.stereotype.Component;

@Component
public class UserService extends ServiceImpl<UserMapper, UserEntity> {

    public UserEntity getByCode(String code){
        LambdaQueryWrapper<UserEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UserEntity::getUserCode, code);

        return this.getOne(lambdaQueryWrapper);
    }

    public UserEntity getUserDtoByRealName(String realName) {
        LambdaQueryWrapper<UserEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UserEntity::getRealName, realName);

        return this.getOne(lambdaQueryWrapper);
    }
}
